import http from '@ohos.net.http'
export default {
    data() {
        return {
            title:'',
            time:'',
            content:'',
        }
    },
    onInit() {
//    获取警报详细信息
        let httpRequest= http.createHttp();
        httpRequest.request("https://v0.yiketianqi.com/api?unescape=1&version=v61&appid=49799419&appsecret=o3baViIp&city=桂林",
            {
                method: 'GET',
                header: {
                    'Content-Type': 'application/json'
                },
                readTimeout: 60000,
                connectTimeout: 60000
            },(err, data) => {
                if (!err) {
                    console.info('Result:' + data.result);
                    this.dataweather=JSON.parse(data.result);
                    this.title=this.dataweather.alarm.alarm_type+this.dataweather.alarm.alarm_level+"预警",
                    this.time="更新时间"+this.dataweather.aqi.update_time,
                    this.content=this.dataweather.alarm.alarm_content

                } else {
                    console.info('error:' + err.data);
                }
            });
    },
}
